package com.tduck.cloud.api.web.controller;

import com.tduck.cloud.account.entity.vo.UserRoleVo;
import com.tduck.cloud.api.web.ao.UserRoleAO;
import com.tduck.cloud.common.util.Result;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

@Slf4j
@RestController
@RequestMapping("/userRole")
@RequiredArgsConstructor
public class UserRoleController {
    private final UserRoleAO userRoleAO;

    @PostMapping("/save")
    public Result<Boolean> save(@RequestBody UserRoleVo userRoleVo) {
        return Result.success(userRoleAO.save(userRoleVo));
    }

    @GetMapping("/list/{userId}")
    public Result<UserRoleVo> listByUserId(@PathVariable @NotNull Long userId) {
        return Result.success(userRoleAO.listByUserId(userId));
    }
}
